using NFreeMarker.Template.Utility;

namespace NFreeMarker.Template
{
    /**
     * A simple implementation of the <tt>TemplateNumberModel</tt>
     * interface. Note that this class is immutable.
     *
     * <p>This class is thread-safe.
     *
     * @author <A HREF="mailto:jon@revusky.com">Jonathan Revusky</A>
     */

    public sealed class SimpleNumber : ITemplateNumberModel //, Serializable
    {
        /**
         * @serial the value of this <tt>SimpleNumber</tt> 
         */
        private readonly Number _value;

        public SimpleNumber(Number value)
        {
            _value = value;
        }

        public SimpleNumber(byte val)
        {
            _value = new Number.ByteNumber(val);
        }

        public SimpleNumber(short val)
        {
            _value = new Number.ShortNumber(val);
        }

        public SimpleNumber(int val)
        {
            _value = new Number.IntNumber(val);
        }

        public SimpleNumber(long val)
        {
            _value = new Number.LongNumber(val);
        }

        public SimpleNumber(sbyte val)
        {
            _value = new Number.SByteNumber(val);
        }

        public SimpleNumber(ushort val)
        {
            _value = new Number.UShortNumber(val);
        }

        public SimpleNumber(uint val)
        {
            _value = new Number.UIntNumber(val);
        }

        public SimpleNumber(ulong val)
        {
            _value = new Number.ULongNumber(val);
        }

        public SimpleNumber(decimal val)
        {
            _value = new Number.DecimalNumber(val);
        }

        public SimpleNumber(double val)
        {
            _value = new Number.DoubleNumber(val);
        }

        public SimpleNumber(float val)
        {
            _value = new Number.FloatNumber(val);
        }

        public Number GetAsNumber()
        {
            return _value;
        }

        public override string ToString()
        {
            return _value.ToString();
        }
    }
}